package cn.com.netedge.iot.frontend.biz.constants;

import cn.com.netedge.iot.model.task.TaskParaModel;
import cn.com.netedge.iot.protocol.dlms.cosem.CosemContext;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class AppConstant {

    public static boolean LOCAL_MODE = false;//本地版模式

    public static final Map<String, CosemContext> COSEM_CONTEXT_MAP = new ConcurrentHashMap<>();

    public static final Map<String, List<TaskParaModel>> TASK_RESULT_MAP = new ConcurrentHashMap<>();

    public static void addTaskResult(String cmdId, TaskParaModel paraModel) {
        List<TaskParaModel> taskList = TASK_RESULT_MAP.get(cmdId);
        if(taskList == null) {
            taskList = new ArrayList<>(10);
            TASK_RESULT_MAP.put(cmdId, taskList);
        }
        taskList.add(paraModel);
    }

    public static void clearTaskResult(String cmdId) {
        TASK_RESULT_MAP.remove(cmdId);
    }

    public static int getTaskResultCount(String cmdId) {
        List<TaskParaModel> taskList = TASK_RESULT_MAP.get(cmdId);
        if(taskList == null) {
            return 0;
        }
        return taskList.size();
    }

    public static List<TaskParaModel> getTaskResultList(String cmdId) {
        return TASK_RESULT_MAP.get(cmdId);
    }

}
